<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: snzo.chen
 * @Date: 2023-11-21 09:50:52
 * @LastEditors: snzo.chen
 * @LastEditTime: 2023-12-01 10:56:08
-->
<template>
  <a-form :model="formState" name="basic">
    <a-form-item
      label="用户名"
      name="username"
      :rules="[{ required: true, message: '请输入用户名!' }]"
    >
      <a-input v-model:value="formState.username" />
    </a-form-item>
    <a-form-item label="状态" name="isOpen">
      <a-switch
        :checked="formState.isOpen === 1"
        checked-children="开启"
        un-checked-children="关闭"
        @click="(checked) => switchClick(checked)"
      />
    </a-form-item>
  </a-form>
</template>
<script lang="ts" setup>
import { reactive } from "vue";
const props = defineProps({
  formData: {
    type: Object,
    default(rawProps) {
      return rawProps;
    },
  },
});
const formState = reactive(props.formData);
const switchClick = (checked) => {
  formState.isOpen = checked ? 1 : 0;
};
defineExpose({
  formState,
});
</script>
<style lang="less" scoped></style>
